var t,
  e,
  n = require('../../@babel/runtime/helpers/typeof'),
  i = '[UMENG] -- ',
  r =
    ((e = !1),
    function () {
      return null === t && (t = new o()), t;
    });
function o() {
  (this.setDebug = function (t) {
    e = t;
  }),
    (this.d = function () {
      if (e)
        try {
          'string' == typeof arguments[0] && (arguments[0] = i + arguments[0]),
            console.debug.apply(console, arguments);
        } catch (t) {}
    }),
    (this.i = function () {
      try {
        if (e)
          try {
            'string' == typeof arguments[0] &&
              (arguments[0] = i + arguments[0]),
              console.info.apply(console, arguments);
          } catch (t) {}
      } catch (t) {}
    }),
    (this.e = function () {
      if (e)
        try {
          'string' == typeof arguments[0] && (arguments[0] = i + arguments[0]),
            console.error.apply(console, arguments);
        } catch (t) {}
    }),
    (this.w = function () {
      if (e)
        try {
          'string' == typeof arguments[0] && (arguments[0] = i + arguments[0]),
            console.warn.apply(console, arguments);
        } catch (t) {}
    }),
    (this.v = function () {
      if (e)
        try {
          'string' == typeof arguments[0] && (arguments[0] = i + arguments[0]),
            console.log.apply(console, arguments);
        } catch (t) {}
    }),
    (this.t = function () {
      if (e)
        try {
          console.table.apply(console, arguments);
        } catch (t) {}
    }),
    (this.tip = function () {
      try {
        'string' == typeof arguments[0] && (arguments[0] = i + arguments[0]),
          console.log.apply(console, arguments);
      } catch (t) {}
    }),
    (this.tip_w = function (t) {
      try {
        console.log(
          '%c ' + i + t,
          'background:red; padding: 4px; padding-right: 8px; border-radius: 4px; color: #fff;',
        );
      } catch (t) {}
    }),
    (this.err = function () {
      try {
        'string' == typeof arguments[0] && (arguments[0] = i + arguments[0]),
          console.error.apply(console, arguments);
      } catch (t) {}
    });
}
var s,
  a =
    ((s = t = null),
    function () {
      return (s = s || new c());
    });
function c() {
  var t = {};
  (this.useOpenid = function () {
    return !!t.useOpenid;
  }),
    (this.useSwanid = function () {
      return !!t.useSwanid;
    }),
    (this.autoGetOpenid = function () {
      return !!t.autoGetOpenid;
    }),
    (this.appKey = function () {
      return t.appKey;
    }),
    (this.uploadUserInfo = function () {
      return t.uploadUserInfo;
    }),
    (this.enableVerify = function () {
      return t.enableVerify;
    }),
    (this.set = function (e) {
      t = e;
    }),
    (this.get = function () {
      return t;
    }),
    (this.setItem = function (e, n) {
      t[e] = n;
    }),
    (this.getItem = function (e) {
      return t[e];
    });
}
function u() {
  (this.listeners = {}), (this.maxListener = 2);
}
(u.prototype.addListener = u.prototype.on =
  function (t, e) {
    var n = this.listeners;
    n[t] && n[t].length >= this.maxListener
      ? console.error('监听器的最大数量是%d,您已超出限制', this.maxListener)
      : n[t] instanceof Array
        ? -1 === n[t].indexOf(e) && n[t].push(e)
        : (n[t] = [].concat(e));
  }),
  (u.prototype.emit = function (t) {
    var e = Array.prototype.slice.call(arguments);
    e.shift();
    var n = this.listeners;
    n[t] instanceof Array &&
      n[t].forEach(function (t) {
        t.apply(null, e);
      });
  }),
  (u.prototype.listeners = function (t) {
    return this.listeners[t];
  }),
  (u.prototype.setMaxListeners = function (t) {
    this.maxListener = t;
  }),
  (u.prototype.removeListener = function (t, e) {
    var n = this.listeners,
      i = (n[t] || []).indexOf(e);
    0 <= i && n[t].splice(i, 1);
  }),
  (u.prototype.removeAllListener = function (t) {
    this.listeners[t] = [];
  }),
  (u.prototype.once = function (t, e) {
    var n = this;
    this.on(t, function i() {
      var r = Array.prototype.slice.call(arguments);
      e.apply(null, r), n.removeListener(t, i);
    });
  });
var f = new u(),
  p = new ((function () {
    function t() {}
    return (
      (t.prototype.setStorage = function (t, e, n) {
        wx.setStorage({
          key: t,
          data: e,
          success: function () {
            'function' == typeof n && n(!0);
          },
          fail: function () {
            'function' == typeof n && n(!1);
          },
        });
      }),
      (t.prototype.getStorage = function (t, e) {
        wx.getStorage({
          key: t,
          success: function (t) {
            'function' == typeof e && e(t.data);
          },
          fail: function (n) {
            r().w(t + ': ' + n.errMsg), 'function' == typeof e && e();
          },
        });
      }),
      (t.prototype.removeStorage = function (t, e) {
        wx.removeStorage({
          key: t,
          success: function () {
            'function' == typeof e && e(!0);
          },
          fail: function () {
            'function' == typeof e && e(!1);
          },
        });
      }),
      (t.prototype.getSystemInfo = function (t) {
        wx.getSystemInfo({
          success: function (e) {
            var n = {
                model: e.model,
                brand: e.brand,
                pixelRatio: e.pixelRatio,
                screenWidth: e.screenWidth,
                screenHeight: e.screenHeight,
                fontSizeSetting: e.fontSizeSetting,
                platform: e.platform,
                platformVersion: e.version,
                platformSDKVersion: e.SDKVersion,
                language: e.language,
                deviceName: e.model,
                OSVersion: e.system,
                resolution: '',
              },
              i = e.system.split(' ');
            Array.isArray(i) && (n.OS = i[0]);
            var r = Math.round(e.screenWidth * e.pixelRatio),
              o = Math.round(e.screenHeight * e.pixelRatio);
            (n.resolution = o < r ? r + '*' + o : o + '*' + r),
              'function' == typeof t && t(n);
          },
          fail: function () {
            'function' == typeof t && t();
          },
        });
      }),
      (t.prototype.getDeviceInfo = function (t) {
        'function' == typeof t && t('');
      }),
      (t.prototype.checkNetworkAvailable = function (t) {
        wx.getNetworkType({
          success: function (e) {
            'function' == typeof t && t(e && 'none' !== e.networkType);
          },
          fail: function () {
            'function' == typeof t && t(!1);
          },
        });
      }),
      (t.prototype.getNetworkInfo = function (t) {
        wx.getNetworkType({
          success: function (e) {
            'function' == typeof t &&
              t({
                networkAvailable: 'none' !== e.networkType,
                networkType: e.networkType,
              });
          },
          fail: function () {
            'function' == typeof t && t();
          },
        });
      }),
      (t.prototype.getDeviceId = function (t) {
        t('');
      }),
      (t.prototype.getAdvertisingId = function (t) {
        'function' == typeof t && t('');
      }),
      (t.prototype.onNetworkStatusChange = function (t) {
        wx.onNetworkStatusChange(function (e) {
          'function' == typeof t && t(e.isConnected);
        });
      }),
      (t.prototype.request = function (t) {
        var e = t.success,
          n = t.fail,
          i = !1,
          r = null;
        (t.success = function (t) {
          i || (r && clearTimeout(r), 'function' == typeof e && e(t));
        }),
          (t.fail = function () {
            i || (r && clearTimeout(r), 'function' == typeof n && n(!1));
          }),
          wx.request(t),
          (r = setTimeout(function () {
            r && clearTimeout(r), (i = !0), 'function' == typeof n && n(i);
          }, t.timeout || 5e3));
      }),
      (t.prototype.getSdkType = function () {
        return 'wxmp';
      }),
      (t.prototype.getPlatform = function () {
        return 'wx';
      }),
      (t.prototype.connectSocket = function (t) {
        wx.connectSocket(t);
      }),
      (t.prototype.closeSocket = function (t) {
        wx.closeSocket(t);
      }),
      (t.prototype.sendSocketMessage = function (t) {
        wx.sendSocketMessage(t);
      }),
      (t.prototype.onSocketOpen = function (t) {
        wx.onSocketOpen(t);
      }),
      (t.prototype.onSocketClose = function (t) {
        wx.onSocketClose(t);
      }),
      (t.prototype.onSocketMessage = function (t) {
        wx.onSocketMessage(t);
      }),
      (t.prototype.onSocketError = function (t) {
        wx.onSocketError(t);
      }),
      (t.prototype.getClipboard = function (t) {
        try {
          wx.getClipboardData({
            success: function (e) {
              'function' == typeof t && t(e.data);
            },
            fail: function () {
              'function' == typeof t && t('');
            },
          });
        } catch (t) {
          r.e('读取clipboard发生错误', t);
        }
      }),
      (t.prototype.showModal = function (t) {
        try {
          wx.showModal(t);
        } catch (t) {
          r.e('展示Modal时发生错误', t);
        }
      }),
      (t.prototype.showToast = function (t) {
        try {
          wx.showToast(t);
        } catch (t) {
          r.e('showToast error', t);
        }
      }),
      (t.prototype.getUserInfo = function (t) {
        var e = {
          fail: function () {
            t && t();
          },
          success: function (e) {
            if (e && e.userInfo) {
              var n = e.userInfo;
              t &&
                t({
                  avatar: n.avatarUrl,
                  nickName: n.nickName,
                  gender: n.gender,
                  country: n.country,
                  province: n.province,
                  city: n.city,
                  language: n.language,
                });
            }
          },
        };
        try {
          wx.getSetting({
            success: function (t) {
              t.authSetting['scope.userInfo'] && wx.getUserInfo(e);
            },
            fail: function () {
              t();
            },
          });
        } catch (t) {
          r.e('getUserInfo error', t);
        }
      }),
      (t.prototype.getAppInfoSync = function () {
        if (wx.getAccountInfoSync) {
          var t = wx.getAccountInfoSync(),
            e = t && t.miniProgram ? t.miniProgram : {};
          return {
            appId: e.appId,
            appEnv: e.envVersion,
            appVersion: e.version,
          };
        }
        return {};
      }),
      (t.prototype.onShareAppMessage = function (t) {
        wx.onShareAppMessage(t);
      }),
      (t.prototype.shareAppMessage = function (t) {
        wx.shareAppMessage(t);
      }),
      t
    );
  })())(),
  d = function (t, e) {
    return (d =
      Object.setPrototypeOf ||
      ({ __proto__: [] } instanceof Array &&
        function (t, e) {
          t.__proto__ = e;
        }) ||
      function (t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
      })(t, e);
  };
function l(t, e) {
  function n() {
    this.constructor = t;
  }
  d(t, e),
    (t.prototype =
      null === e ? Object.create(e) : ((n.prototype = e.prototype), new n()));
}
var h,
  v,
  g = {
    SESSION_INTERVAL: 3e4,
    LOG_URL: 'https://umini.shujupie.com/wxm_logs',
    GET_OPENID_URL: 'https://umini.shujupie.com/uminiprogram_logs/wx/getuut',
    USERINFO_URL: 'https://umini.shujupie.com/uminiprogram_logs/comm/uif',
    DEVICE_INFO_KEY: 'device_info',
    ADVERTISING_ID: 'mobile_ad_id',
    ANDROID_ID: 'android_id',
    CURRENT_SESSION: 'current_session',
    SESSION_PAUSE_TIME: 'session_pause_time',
    EVENT_SEND_DEFAULT_INTERVAL: 15e3,
    EVENT_LAST_SEND_TIME: 'last_send_time',
    MAX_EVENTID_LENGTH: 128,
    MAX_PROPERTY_KEY_LENGTH: 256,
    MAX_PROPERTY_KEYS_COUNT: 100,
    REPORT_POLICY: 'report_policy',
    REPORT_INTERVAL_TIME: 'report_interval_time',
    REPORT_POLICY_START_SEND: '1',
    REPORT_POLICY_INTERVAL: '6',
    IMPRINT: 'imprint',
    SEED_VERSION: '1.0.0',
    IMPL_VERSION: '2.4.6',
    ALIPAY_AVAILABLE_VERSION: '10.1.52',
    SHARE_PATH: 'um_share_path',
    SHARES: 'shares',
    REQUESTS: 'requests',
    UUID: 'um_uuid',
    UUID_SUFFIX: 'ud',
    OPENID: 'um_od',
    UNIONID: 'um_unid',
    ALIPAYID: 'um_alipayid',
    USERID: 'um_userid',
    PROVIDER: 'um_provider',
    SWANID: 'um_swanid',
    ANONYMOUSID: 'um_anonymousid',
    LAUNCH_OPTIONS: 'LAUNCH_OPTIONS',
    UM_SSRC: '_um_ssrc',
    USER_INFO: 'user_info',
    IS_ALIYUN: !1,
    ALIYUN_URL: 'serverless.huoban.youmeng.network.forward',
  },
  y = function (t) {
    for (
      var e = '',
        n = [
          '0',
          '1',
          '2',
          '3',
          '4',
          '5',
          '6',
          '7',
          '8',
          '9',
          'a',
          'b',
          'c',
          'd',
          'e',
          'f',
          'g',
          'h',
          'i',
          'j',
          'k',
          'l',
          'm',
          'n',
          'o',
          'p',
          'q',
          'r',
          's',
          't',
          'u',
          'v',
          'w',
          'x',
          'y',
          'z',
          'A',
          'B',
          'C',
          'D',
          'E',
          'F',
          'G',
          'H',
          'I',
          'J',
          'K',
          'L',
          'M',
          'N',
          'O',
          'P',
          'Q',
          'R',
          'S',
          'T',
          'U',
          'V',
          'W',
          'X',
          'Y',
          'Z',
        ],
        i = 0;
      i < Number(t);
      i++
    )
      e += n[Math.round(Math.random() * (n.length - 1))];
    return e;
  },
  _ = function (t) {
    return JSON.parse(JSON.stringify(t));
  },
  m = function (t, e) {
    return (
      !(!t || !e || 0 === e.length || e.length > t.length) &&
      t.substr(0, e.length) === e
    );
  },
  S = function (t) {
    if (null == t)
      throw new TypeError('Cannot convert undefined or null to object');
    for (var e = Object(t), n = 1; n < arguments.length; n++) {
      var i = arguments[n];
      if (i)
        for (var r in i)
          Object.prototype.hasOwnProperty.call(i, r) && (e[r] = i[r]);
    }
    return e;
  },
  I = function t(e, i) {
    if (e === i) return !0;
    if (e && 'object' == n(e) && i && 'object' == n(i)) {
      if (Object.keys(e).length !== Object.keys(i).length) return !1;
      for (var r in e) {
        if (Object.prototype.hasOwnProperty.call(i, r)) return !1;
        if (!t(e[r], i[r])) return !1;
      }
      return !0;
    }
    return !1;
  },
  E = function (t, e) {
    if (!t) return '';
    if ('string' == typeof e && e.length) {
      var n = new RegExp('^' + e + '*');
      t = t.replace(n, '');
    } else t = t.replace(/^s*/, '');
    return t;
  },
  O = (function (t) {
    function e() {
      return (null !== t && t.apply(this, arguments)) || this;
    }
    return (
      l(e, t),
      (e.prototype.getOpenIdAsync = function (t, e) {
        var n = this;
        wx.login({
          success: function (i) {
            i.code
              ? p.request({
                  url: g.GET_OPENID_URL,
                  method: 'GET',
                  data: { key: t, code: i.code },
                  success: function (t) {
                    if (t && 200 === t.statusCode && t.data && t.data.data) {
                      var i = t.data.data;
                      return (
                        n.setOpenid(i.oid), n.setUnionid(i.uid), e && e(!0)
                      );
                    }
                    e && e();
                  },
                  fail: function (t) {
                    r().v('wx request failed...', t), e && e();
                  },
                })
              : e && e();
          },
          fail: function () {
            e && e();
          },
        });
      }),
      e
    );
  })(
    (function (t) {
      function e() {
        var e = (null !== t && t.apply(this, arguments)) || this;
        return (e._openid = ''), (e._unionid = ''), (e._useOpenid = !1), e;
      }
      return (
        l(e, t),
        (e.prototype.initID = function (t) {
          var e = this;
          (e._idType = e._useOpenid ? 'openid' : 'uuid'),
            r().v('id type: ', e._idType),
            p.getStorage(g.UNIONID, function (t) {
              e._unionid = t;
            }),
            this._useOpenid
              ? p.getStorage(g.OPENID, function (n) {
                  (e._openid = n), t && t();
                })
              : t && t();
        }),
        (e.prototype.setUseOpenid = function (t) {
          this._useOpenid = t;
        }),
        (e.prototype.setOpenid = function (t) {
          !this._openid && t && ((this._openid = t), p.setStorage(g.OPENID, t));
        }),
        (e.prototype.setUnionid = function (t) {
          !this._unionid &&
            t &&
            ((this._unionid = t), p.setStorage(g.UNIONID, t));
        }),
        (e.prototype.getIdTracking = function () {
          var e = t.prototype.getIdTracking.call(this);
          return (
            this._openid && (e.openid = this._openid),
            this._unionid && (e.unionid = this._unionid),
            this._userid && (e.userid = this._userid),
            e
          );
        }),
        (e.prototype.getId = function () {
          return this._useOpenid ? this._openid : this._uuid;
        }),
        e
      );
    })(
      (function () {
        function t() {
          (this._uuid = ''),
            (this._userid = ''),
            (this._provider = ''),
            (this._idType = '');
        }
        return (
          (t.prototype.createUUID = function () {
            return y(10) + Date.now() + y(7) + g.UUID_SUFFIX;
          }),
          (t.prototype.initUUID = function (t) {
            var e = this;
            p.getStorage(g.UUID, function (n) {
              n
                ? (e._uuid = n)
                : ((e._uuid = e.createUUID()), p.setStorage(g.UUID, e._uuid)),
                t && t(n);
            });
          }),
          (t.prototype.initUserid = function () {
            var t = this;
            p.getStorage(g.USERID, function (e) {
              !t._userid && e && ((t._userid = e), r().v('userId is ', e));
            }),
              p.getStorage(g.PROVIDER, function (e) {
                !t._provider &&
                  e &&
                  ((t._provider = e), r().v('provider is ', e));
              });
          }),
          (t.prototype.init = function (t) {
            var e = this;
            e.initUUID(function () {
              e.initUserid(), e.initID(t);
            });
          }),
          (t.prototype.setUserid = function (t, e) {
            !this._userid &&
              t &&
              ((this._userid = t),
              (this._provider = e),
              p.setStorage(g.USERID, t),
              p.setStorage(g.PROVIDER, e));
          }),
          (t.prototype.getUserId = function () {
            return this._userid;
          }),
          (t.prototype.getProvider = function () {
            return this._provider;
          }),
          (t.prototype.getIdType = function () {
            return this._idType;
          }),
          (t.prototype.getIdTracking = function () {
            var t = {};
            return (
              this._uuid && (t.uuid = this._uuid),
              this._userid && (t.userid = this._userid),
              t
            );
          }),
          t
        );
      })(),
    ),
  ),
  A = function () {
    return (h = h || new O());
  },
  w = function () {
    return (v = v || new T());
  };
function T() {
  var t = !1,
    e = null,
    n = [];
  (this.addPageStart = function (n) {
    n && !t && ((e = { ts: Date.now(), path: n, page_name: n }), (t = !0));
  }),
    (this.addPageEnd = function (i) {
      if (t && i && e && i === e.page_name) {
        var r = Date.now() - e.ts;
        (e.duration = Math.abs(r)), n.push(e), (e = null), (t = !1);
      }
    }),
    (this.get = function () {
      return n;
    }),
    (this.getCurrentPage = function () {
      return e;
    }),
    (this.clear = function () {
      n.length = 0;
    });
}
var k = {};
var N,
  U,
  b,
  R = function () {
    return (N = N || new P());
  };
function P() {
  return {
    add: function (t, e) {
      r().v('share origin: %o', t);
      var n = {
        title: t && t.title,
        path: t && t.path && t.path.split('?')[0],
        _um_sts: Date.now(),
      };
      n.path &&
        1 < n.path.length &&
        m(n.path, '/') &&
        (n.path = E(n.path, '/'));
      var i = t.path || '',
        o = A().getId();
      if (o) {
        var s = b.split(','),
          a = (s = s.filter(function (t) {
            return 0 < t.length;
          })).indexOf(o);
        0 <= a && (s = s.slice(0, a)), s.length < 3 && s.push(o);
        var c = s.join(',');
        -1 !== i.indexOf('?')
          ? (i += '&_um_ssrc=' + c)
          : (i += '?_um_ssrc=' + c);
        var u = Date.now();
        if (((i += '&_um_sts=' + u), e)) {
          var f = (function (t) {
              var e = [];
              for (var n in t)
                '_um_ssrc' !== n && '_um_sts' !== n && e.push(n + '=' + t[n]);
              return e.join('&');
            })(k),
            p = f
              ? f + '&_um_ssrc=' + c + '&_um_sts=' + u
              : '_um_ssrc=' + c + '&_um_sts=' + u;
          t.query = t.query ? t.query + '&_um_ssrc=' + c + '&_um_sts=' + u : p;
        } else t.path = i;
        (n._um_ssrc = c), (n._um_sts = u);
      }
      return U.push(n), r().v('share: %o', t), t;
    },
    setShareSource: function (t) {
      b = t;
    },
    clear: function () {
      U.length = 0;
    },
    get: function () {
      return U;
    },
  };
}
var D,
  L,
  C,
  x,
  M = function (t) {
    if (t)
      try {
        return JSON.stringify(t);
      } catch (t) {}
    return '';
  },
  V = function (t) {
    if (t)
      try {
        return JSON.parse(t);
      } catch (t) {}
    return null;
  },
  j =
    ((x = !(U = [])),
    function () {
      return (D = D || new G());
    });
function G() {
  (this.load = function (t) {
    C
      ? (p.removeStorage(L), t())
      : ((L = 'um_cache_' + a().appKey()),
        p.getStorage(L, function (e) {
          (C = V(e) || {}), (x = !0), p.removeStorage(L), t();
        }));
  }),
    (this.save = function () {
      C && p.setStorage(L, M(C));
    }),
    (this.set = function (t, e) {
      C && (C[t] = e);
    }),
    (this.get = function (t) {
      return (C || {})[t];
    }),
    (this.remove = function (t) {
      C && C[t] && delete C[t];
    }),
    (this.getAll = function () {
      return C;
    }),
    (this.clear = function () {
      C = null;
    }),
    (this.has = function (t) {
      return !!this.get(t);
    }),
    (this.isLoaded = function () {
      return x;
    });
}
var K,
  F,
  q,
  H,
  Y = 'ekvs',
  J =
    ((q = []),
    (H = []),
    function () {
      return (K = K || {
        addEvent: function (t) {
          F
            ? (q.unshift(t),
              1 < q.length &&
                (!(function () {
                  if (q.length) {
                    var t = j().get(Y);
                    (function (t) {
                      var e = 0;
                      for (var n in t)
                        Array.isArray(t[n]) && (e += t[n].length);
                      return e;
                    })(t) +
                      q.length <=
                      1e4 && ((t = X(t, q)), j().set(Y, t));
                  }
                })(),
                (q.length = 0)))
            : (r().w('session id is null: ', F), H.unshift(t));
        },
        setSessionId: function (t) {
          if (
            ((F = t),
            r().v('setSessionId: ', F),
            Array.isArray(H) && H.length && F)
          ) {
            for (var e = 0; e < H.length; e++) this.addEvent(H[e]);
            H.length = 0;
          }
        },
        getEkvs: function () {
          var t = j().get(Y);
          return q && q.length && (t = X(t, q)), t;
        },
        clear: function () {
          j().remove(Y), (q.length = 0);
        },
      });
    });
function X(t, e) {
  var n = (t = t || {})[F];
  return (
    Array.isArray(n) && n.length ? (t[F] = n.concat(e)) : (t[F] = [].concat(e)),
    t
  );
}
var z,
  Q = 'half_session',
  W = 'close_session',
  B = 'ekv',
  Z = ['access', 'access_subtype'],
  $ = function () {
    return (z =
      z ||
      (function () {
        var t = !1,
          e = {};
        return {
          init: function () {
            !(function (t) {
              var n = j().get(g.IMPRINT);
              n && (e.imprint = n),
                (e.device_type = 'Phone'),
                (e.sdk_version = g.IMPL_VERSION),
                (e.appkey = a().appKey()),
                p.getDeviceInfo(function (t) {
                  e.device_info = t || '';
                });
              var i = p.getAppInfoSync();
              (e.appid = i.appId),
                (e.app_env = i.appEnv),
                (e.app_version = i.appVersion),
                p.getSystemInfo(function (n) {
                  p.getNetworkInfo(function (i) {
                    var o = (function (t, e) {
                      var n = {},
                        i = (e = e || {}).networkType;
                      'none' === i && (i = 'unknown');
                      var r = t.model || '',
                        o = t.platform || '',
                        s = t.brand || '',
                        a = s.toLowerCase();
                      switch (
                        ((n.sdk_type = p.getSdkType()),
                        (n.platform = p.getPlatform()),
                        (n.platform_sdk_version = t.platformSDKVersion),
                        (n.platform_version = t.platformVersion),
                        (n.resolution = t.resolution),
                        (n.pixel_ratio = t.pixelRatio),
                        (n.os = o),
                        (n.font_size_setting = t.fontSizeSetting),
                        (n.device_model = r),
                        (n.device_brand = s),
                        (n.device_manufacturer = a),
                        (n.device_manuid = r),
                        (n.device_name = r),
                        (n.os_version = t.OSVersion),
                        (n.language = t.language),
                        (i = i ? i.toLowerCase() : ''))
                      ) {
                        case '4g':
                          (n.access_subtype = 'LTE'), (n.access = '4G');
                          break;
                        case '3g':
                          (n.access_subtype = 'CDMA'), (n.access = '3G');
                          break;
                        case '2g':
                          (n.access_subtype = 'GRPS'), (n.access = '2G');
                          break;
                        default:
                          (n.access = i), delete n.access_subtype;
                      }
                      return n;
                    })(n, i);
                    S(e, o),
                      (function (t) {
                        var n = [];
                        n.push({ name: '设备型号', value: e.device_model }),
                          n.push({ name: '设备生产商', value: e.device_brand }),
                          n.push({ name: 'os版本号', value: e.os_version }),
                          n.push({ name: '网络类型', value: e.access }),
                          n.push({ name: '运营商', value: e.access_subtype }),
                          n.push({ name: '分辨率', value: e.resolution }),
                          n.push({ name: 'pixelRatio', value: e.pixel_ratio });
                        for (var i = '', o = 0; o < n.length; o++) {
                          var s = n[o];
                          i += s.name + ': ' + s.value + '; ';
                        }
                        r().v('调试辅助信息: ', i);
                      })(),
                      t && t();
                  });
                });
            })(function () {
              t = !0;
            });
          },
          isLoaded: function () {
            return t;
          },
          get: function () {
            return e;
          },
          getRealtimeFields: function () {
            var t = {};
            return (
              Z.forEach(function (n) {
                t[n] = e[n];
              }),
              t
            );
          },
          setIdTracking: function (t) {
            this.setItem('id_tracking', t);
          },
          setIdType: function (t) {
            this.setItem('id_type', t);
          },
          setAppVersion: function (t) {
            this.setItem('app_version', t);
          },
          setSuperProperty: function (t) {
            e.sp || (e.sp = {}), (e.sp.isv = t);
          },
          getSuperProperty: function () {
            return e && e.sp ? e.sp.isv : '';
          },
          setItem: function (t, n) {
            e[t] = n;
          },
          getItem: function (t) {
            return e[t];
          },
        };
      })());
  };
var tt,
  et,
  nt,
  it = function () {
    return (tt = tt || {
      resume: function (t) {
        var e = !1;
        nt = nt || j().get(g.CURRENT_SESSION);
        var n = new Date();
        return (
          (et = n.getTime()),
          !nt || !nt.end_time || et - nt.end_time > g.SESSION_INTERVAL
            ? ((e = !0),
              (function (t) {
                try {
                  var e = (nt || {}).options || {},
                    n = S(
                      {},
                      (function (t) {
                        var e = {};
                        for (var n in t)
                          0 === n.indexOf('_um_') && (e[n] = t[n]);
                        return r().v('query: ', t), r().v('_um_params: ', e), e;
                      })(t.query),
                    );
                  (n.path = t.path || e.path),
                    (n.scene = t.scene
                      ? p.getPlatform() + '_' + t.scene
                      : e.scene);
                  var i = t.referrerInfo;
                  i && (n.referrerAppId = i.appId),
                    r().v('session options: ', n);
                  var o = n[g.UM_SSRC];
                  o && R().setShareSource(o);
                  var s = Date.now();
                  nt = { id: y(10) + s, start_time: s, options: n };
                } catch (t) {
                  r().e('生成新session失败: ', t);
                }
              })(t),
              r().v('开始新的session(%s): ', nt.id, nt))
            : r().v(
                '延续上一次session(%s): %s ',
                nt.id,
                n.toLocaleTimeString(),
                nt,
              ),
          e
        );
      },
      pause: function () {
        !(function () {
          if (nt) {
            var t = new Date();
            (nt.end_time = t.getTime()),
              'number' != typeof nt.duration && (nt.duration = 0),
              (nt.duration = nt.end_time - et),
              j().set(g.CURRENT_SESSION, nt),
              r().v('退出会话(%s): %s ', nt.id, t.toLocaleTimeString(), nt);
          }
        })();
      },
      getCurrentSessionId: function () {
        return (nt || {}).id;
      },
      getCurrentSession: function () {
        return nt;
      },
      cloneCurrentSession: function () {
        return _(nt);
      },
    });
  };
var rt = { sessions: 'sn', ekvs: 'e', active_user: 'active_user' },
  ot = {
    sdk_type: 'sdt',
    access: 'ac',
    access_subtype: 'acs',
    device_model: 'dm',
    language: 'lang',
    device_type: 'dt',
    device_manufacturer: 'dmf',
    device_name: 'dn',
    platform_version: 'pv',
    id_type: 'it',
    font_size_setting: 'fss',
    os_version: 'ov',
    device_manuid: 'did',
    platform_sdk_version: 'psv',
    device_brand: 'db',
    appkey: 'ak',
    _id: 'id',
    id_tracking: 'itr',
    imprint: 'imp',
    sdk_version: 'sv',
    resolution: 'rl',
    testToken: 'ttn',
  },
  st = {
    uuid: 'ud',
    unionid: 'und',
    openid: 'od',
    anonymousid: 'nd',
    alipay_id: 'ad',
    device_id: 'dd',
    userid: 'puid',
  };
function at(t, e) {
  var n = {};
  for (var i in t) e[i] ? (n[e[i]] = t[i]) : (n[i] = t[i]);
  return n;
}
var ct,
  ut,
  ft = '_UMTEST_',
  pt = 'TEST_TOKEN',
  dt =
    ((ct = nt = et = tt = z = C = D = N = v = h = null),
    (ut = L = b = ''),
    function () {
      return (ct = ct || new lt());
    });
function lt() {
  (this.init = function (t) {
    p.getClipboard(function (e) {
      ut = j().get(pt);
      try {
        if (e && m(e, ft) && e.split(ft)[1]) {
          var n = e.split(ft)[1],
            i = JSON.parse(n).token;
          i && ((ut = i), j().set(pt, i));
        }
      } catch (e) {
        r().v(e);
      }
      t(!!ut);
    });
  }),
    (this.getToken = function () {
      return ut;
    }),
    (this.clear = function () {
      (ut = ''), j().remove(pt);
    });
}
function ht(t) {
  if (t.length < 2)
    return (e = t.charCodeAt(0)) < 128
      ? t
      : e < 2048
        ? It(192 | (e >>> 6)) + It(128 | (63 & e))
        : It(224 | ((e >>> 12) & 15)) +
          It(128 | ((e >>> 6) & 63)) +
          It(128 | (63 & e));
  var e = 65536 + 1024 * (t.charCodeAt(0) - 55296) + (t.charCodeAt(1) - 56320);
  return (
    It(240 | ((e >>> 18) & 7)) +
    It(128 | ((e >>> 12) & 63)) +
    It(128 | ((e >>> 6) & 63)) +
    It(128 | (63 & e))
  );
}
function vt(t) {
  var e = [0, 2, 1][t.length % 3],
    n =
      (t.charCodeAt(0) << 16) |
      ((1 < t.length ? t.charCodeAt(1) : 0) << 8) |
      (2 < t.length ? t.charCodeAt(2) : 0);
  return [
    mt.charAt(n >>> 18),
    mt.charAt((n >>> 12) & 63),
    2 <= e ? '=' : mt.charAt((n >>> 6) & 63),
    1 <= e ? '=' : mt.charAt(63 & n),
  ].join('');
}
function gt(t) {
  return t.replace(Et, ht).replace(/[\s\S]{1,3}/g, vt);
}
function yt(t) {
  switch (t.length) {
    case 4:
      var e =
        (((7 & t.charCodeAt(0)) << 18) |
          ((63 & t.charCodeAt(1)) << 12) |
          ((63 & t.charCodeAt(2)) << 6) |
          (63 & t.charCodeAt(3))) -
        65536;
      return It(55296 + (e >>> 10)) + It(56320 + (1023 & e));
    case 3:
      return It(
        ((15 & t.charCodeAt(0)) << 12) |
          ((63 & t.charCodeAt(1)) << 6) |
          (63 & t.charCodeAt(2)),
      );
    default:
      return It(((31 & t.charCodeAt(0)) << 6) | (63 & t.charCodeAt(1)));
  }
}
function _t(t) {
  var e = t.length,
    n = e % 4,
    i =
      (0 < e ? St[t.charAt(0)] << 18 : 0) |
      (1 < e ? St[t.charAt(1)] << 12 : 0) |
      (2 < e ? St[t.charAt(2)] << 6 : 0) |
      (3 < e ? St[t.charAt(3)] : 0),
    r = [It(i >>> 16), It((i >>> 8) & 255), It(255 & i)];
  return (r.length -= [0, 0, 2, 1][n]), r.join('');
}
var mt = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
  St = (function (t) {
    for (var e = {}, n = 0, i = t.length; n < i; n++) e[t.charAt(n)] = n;
    return e;
  })(mt),
  It = String.fromCharCode,
  Et = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,
  Ot = new RegExp(['[À-ß][-¿]', '[à-ï][-¿]{2}', '[ð-÷][-¿]{3}'].join('|'), 'g'),
  At = function (t, e) {
    return e
      ? gt(String(t))
          .replace(/[+\/]/g, function (t) {
            return '+' == t ? '-' : '_';
          })
          .replace(/=/g, '')
      : gt(String(t));
  },
  wt = function (t) {
    return (function (t) {
      return t.replace(/[\s\S]{1,4}/g, _t).replace(Ot, yt);
    })(
      String(t)
        .replace(/[-_]/g, function (t) {
          return '-' == t ? '+' : '/';
        })
        .replace(/[^A-Za-z0-9\+\/]/g, ''),
    );
  },
  Tt = new (function () {
    var t = {};
    (this.set = function (e) {
      t = V(wt(e));
    }),
      (this.get = function () {
        return t;
      }),
      (this.getItem = function (e) {
        if (t) return t[e];
      }),
      (this.load = function () {
        t = j().get(g.IMPRINT);
      }),
      (this.save = function () {
        t && j().set(g.IMPRINT, t);
      });
  })();
function kt(t, e, n, i) {
  $().setIdType(A().getIdType()), $().setIdTracking(A().getIdTracking());
  var o = A().getUserId();
  o &&
    t.analytics &&
    (t.analytics.active_user = { puid: o, provider: A().getProvider() });
  var s = _($().get());
  t.header = S(s, t.header, {
    ts: Date.now(),
    testToken: dt().getToken(),
    traceId: y(10) + Date.now() + y(9),
  });
  var a,
    c = (function (t) {
      return {
        h: (function (t, e) {
          var n = at(t, e);
          return (
            t &&
              t.id_tracking &&
              (n[e.id_tracking || 'id_tracking'] = at(t.id_tracking, st)),
            n
          );
        })(t.header, ot),
        a: (function (t, e) {
          var n = {};
          if (t) for (var i in t) t[i] && (n[e[i]] = t[i]);
          return n;
        })(t.analytics, rt),
      };
    })(t),
    u = M(c),
    f = {
      url: g.LOG_URL,
      method: 'POST',
      data: At(u),
      success: function (i) {
        var o = i.code || i.status || i.statusCode;
        200 === o || 413 === o
          ? (r().i('数据发送成功: ', t, u),
            (function (t) {
              t &&
                ($().setItem(g.IMPRINT, t),
                Tt.set(t),
                Tt.save(),
                r().v('imprint: ', Tt.get()),
                Tt.getItem('ttn_invalid') && dt().clear());
            })((i.data || {}).imprint),
            'function' == typeof e && e(i))
          : (r().w('数据发送失败: ', u), 'function' == typeof n && n());
      },
      fail: function (t) {
        r().w('超时: ', u), 'function' == typeof n && n();
      },
      complete: function () {
        'function' == typeof i && i();
      },
    };
  p.request(
    S(f, {
      header: { 'Content-Type': (a = p.getSdkType() + '/json'), 'Msg-Type': a },
    }),
  );
}
var Nt,
  Ut,
  bt,
  Rt,
  Pt =
    ((Nt = null),
    (Ut = !1),
    (bt = []),
    (Rt = new (function (t) {
      var e = t,
        n = [];
      (this.enqueue = function (t) {
        'number' == typeof e && this.size() >= e && this.dequeue(), n.push(t);
      }),
        (this.dequeue = function () {
          return n.shift();
        }),
        (this.front = function () {
          return n[0];
        }),
        (this.isEmpty = function () {
          return 0 === n.length;
        }),
        (this.clear = function () {
          n.length = 0;
        }),
        (this.size = function () {
          return n.length;
        }),
        (this.items = function () {
          return n;
        }),
        (this.print = function () {
          console.log(n.toString());
        });
    })(50)),
    function () {
      return (Nt = Nt || new Lt());
    });
function Dt(t) {
  A().getId()
    ? Ut
      ? r().i('队列正在发送中')
      : ((Ut = !0),
        (function t(e) {
          var n = Rt.front();
          n
            ? kt(
                n,
                function () {
                  Rt.dequeue(), t(e);
                },
                function () {
                  var n = Rt.dequeue();
                  n && !n.noCache && bt.push(n), t(e);
                },
              )
            : (bt.forEach(function (t) {
                Rt.enqueue(t);
              }),
              (bt.length = 0),
              e());
        })(function () {
          (Ut = !1), 'function' == typeof t && t();
        }))
    : (r().i('获取id标识失败，暂缓发送'), 'function' == typeof t && t());
}
function Lt() {
  (this.send = function (t, e, n) {
    t
      ? this.add(t, e, function () {
          Dt(n);
        })
      : Dt(n);
  }),
    (this.add = function (t, e, n) {
      !(function t(e, n, i) {
        if ($().isLoaded()) {
          n = n || {};
          var r = (function (t) {
            var e = null;
            switch (t) {
              case Q:
                e = (function () {
                  var t = null,
                    e = it().cloneCurrentSession();
                  return (
                    e &&
                      (t = {
                        header: { st: '1' },
                        analytics: { sessions: [e] },
                      }),
                    t
                  );
                })();
                break;
              case W:
                e = (function () {
                  var t = null,
                    e = {},
                    n = it().cloneCurrentSession();
                  if (n) {
                    var i = w().get(),
                      r = R().get();
                    Array.isArray(i) && i.length && (n.pages = _(i)),
                      Array.isArray(r) && r.length && (n.shares = _(r)),
                      w().clear(),
                      R().clear(),
                      (e.sessions = [n]);
                  }
                  var o = J().getEkvs();
                  return (
                    o && ((e.ekvs = _(o)), J().clear()),
                    (e.sessions || e.ekvs) && (t = { analytics: e }),
                    t
                  );
                })();
                break;
              case B:
                e = (function () {
                  var t = null,
                    e = J().getEkvs();
                  return (
                    e && ((t = { analytics: { ekvs: _(e) } }), J().clear()), t
                  );
                })();
            }
            return e;
          })(e);
          if (r) {
            var o = $().getRealtimeFields();
            (r.header = S({}, r.header, o)),
              (r.noCache = n.noCache),
              Rt.enqueue(r);
          }
          'function' == typeof i && i();
        } else
          setTimeout(function () {
            t(e, n, i);
          }, 100);
      })(t, e, n);
    }),
    (this.load = function () {
      var t = j().get(g.REQUESTS);
      t &&
        t.length &&
        t.forEach(function (t) {
          Rt.enqueue(t);
        }),
        j().remove(g.REQUESTS);
    }),
    (this.save = function () {
      j().set(g.REQUESTS, _(Rt.items())), Rt.clear();
    });
}
var Ct,
  xt =
    ((Ct = null),
    function () {
      return (Ct = Ct || new Mt());
    });
function Mt() {
  this.update = function () {
    p.getUserInfo(function (t) {
      if (t) {
        var e = j().get(g.USER_INFO);
        (e && I(t, e)) ||
          (function (t, e) {
            var n = a().appKey(),
              i = p.getSdkType(),
              o = A().getId(),
              s = A().getIdType();
            if (n && i && o && s) {
              var c = {
                  ak: a().appKey(),
                  sdt: p.getSdkType(),
                  uin: t.nickName,
                  uia: t.avatar,
                  uig: t.gender,
                  uit: t.country,
                  uip: t.province,
                  uic: t.city,
                  uil: t.language,
                  id: A().getId(),
                  it: A().getIdType(),
                },
                u = JSON.stringify(c);
              (u = At(u)),
                p.request({
                  url: g.USERINFO_URL,
                  method: 'POST',
                  header: {
                    'content-type': 'application/x-www-form-urlencoded',
                  },
                  data: 'ui=' + u,
                  success: function (n) {
                    r().v('用户信息上传成功: ', t),
                      e && e(n && n.data && 200 === n.data.code);
                  },
                  fail: function () {
                    r().e('用户信息上传失败: ', t), e && e(!1);
                  },
                });
            }
          })(t, function (e) {
            e && j().set(g.USER_INFO, t);
          });
      }
    });
  };
}
function Vt(t, e) {
  (this.id = t), (this.ts = Date.now());
  var i = n(e);
  if ('string' == i && e) this[t] = e;
  else if ('object' == i)
    for (var r in e) !{}.hasOwnProperty.call(e, r) || (this[r] = e[r]);
}
function jt() {
  var t = !1,
    e = !1,
    i = 0;
  (this.init = function (e) {
    r().v('sdk version: ' + g.IMPL_VERSION),
      t
        ? r().v('Lib重复实例化')
        : j().load(function () {
            r().v('cache初始化成功: ', j().getAll()),
              A().setUseOpenid && A().setUseOpenid(a().useOpenid()),
              A().init(function () {
                $().init(), r().v('Header初始化成功');
              }),
              (t = !0),
              'function' == typeof e && e(),
              r().tip('SDK集成成功');
          });
  }),
    (this.resume = function (n) {
      if (t && !e) {
        r().v('showOptions: ', n);
        var i = this;
        (e = !0),
          a().enableVerify()
            ? dt().init(function () {
                i._resume(n);
              })
            : i._resume(n);
      }
    }),
    (this._resume = function (t) {
      Pt().load();
      var e = it().resume(t),
        n = it().getCurrentSessionId();
      J().setSessionId(n),
        e &&
          Pt().add(Q, {}, function () {
            A().setUseOpenid && A().setUseOpenid(a().useOpenid()),
              a().useOpenid() && a().autoGetOpenid() && !A().getId()
                ? (r().v('get id async'),
                  (function t(e, n) {
                    A().getId() ||
                      e <= 0 ||
                      A().getOpenIdAsync(a().appKey(), function (i) {
                        i
                          ? (r().v('获取id成功'), Pt().send())
                          : (r().v(
                              '获取openid失败,启动重试,剩余可用次数',
                              e - 1,
                            ),
                            setTimeout(function () {
                              t(e - 1, n);
                            }, n));
                      });
                  })(10, 3e3))
                : (r().v('session auto send'), Pt().send());
          });
    }),
    (this.pause = function (n) {
      t &&
        ((e = !1),
        (i = 0),
        it().pause(),
        a().uploadUserInfo() && xt().update(),
        Pt().send(W, {}, function () {
          Pt().save(),
            j().save(),
            r().v('cache save success'),
            'function' == typeof n && n();
        }));
    }),
    (this.setOpenid = function (t) {
      r().v('setOpenId: %s', t), A().setOpenid(t), Pt().send();
    }),
    (this.setUnionid = function (t) {
      r().v('setUnionid: %s', t), A().setUnionid(t);
    }),
    (this.setUserid = function (t, e) {
      r().v('setUserid: %s', t, e), A().setUserid(t, e);
    }),
    (this.setAnonymousid = function (t) {
      r().v('setAnonymousId: %s', t), A().setAnonymousid(t), Pt().send();
    }),
    (this.setAppVersion = function (t) {
      t && 'string' != typeof t
        ? r().w('setAppVersion方法只接受字符串类型参数')
        : $().setAppVersion(t);
    }),
    (this.setAlipayUserid = function (t) {
      t && 'string' != typeof t
        ? r().w('setAlipayUserid方法只接受字符串类型参数')
        : (r().v('setAlipayUserid: %s', t), A().setAlipayUserid(t));
    }),
    (this.setSuperProperty = function (t) {
      if (t && 'string' != typeof t) r().w('超级属性只支持字符串类型');
      else {
        var e = this;
        $().getSuperProperty() !== t &&
          ($().setSuperProperty(t),
          e.pause(function () {
            e.resume();
          }));
      }
    }),
    (this.trackEvent = function (e, o) {
      var s;
      if (
        t &&
        (r().v('event: ', e, o),
        (function (t, e) {
          if (t && 'string' == typeof t) {
            var i = ['id', 'ts', 'du'],
              o = {};
            if (
              (i.forEach(function (t) {
                o[t] = 1;
              }),
              o[t])
            )
              r().e('eventId不能与以下保留字冲突: ' + i.join(','));
            else if (t.length > g.MAX_EVENTID_LENGTH)
              r().e(
                'The maximum length of event id shall not exceed ' +
                  g.MAX_EVENTID_LENGTH,
              );
            else {
              if (
                !e ||
                ('object' == n(e) && !Array.isArray(e)) ||
                'string' == typeof e
              ) {
                if ('object' == n(e)) {
                  var s = 0;
                  for (var a in e)
                    if ({}.hasOwnProperty.call(e, a)) {
                      if (a.length > g.MAX_PROPERTY_KEY_LENGTH)
                        return void r().e(
                          'The maximum length of property key shall not exceed ' +
                            g.MAX_PROPERTY_KEY_LENGTH,
                        );
                      if (s >= g.MAX_PROPERTY_KEYS_COUNT)
                        return void r().e(
                          'The maximum count of properties shall not exceed ' +
                            g.MAX_PROPERTY_KEYS_COUNT,
                        );
                      if (o[a])
                        return void r().e(
                          '属性中的key不能与以下保留字冲突: ' + i.join(','),
                        );
                      s += 1;
                    }
                }
                return 1;
              }
              r().e(
                'please check trackEvent properties. properties should be string or object(not include Array)',
              );
            }
          } else
            r().e(
              'please check trackEvent id. id should be "string" and not null',
            );
        })(e, o))
      ) {
        var a = new Vt(e, o);
        J().addEvent(a);
        var c = !!dt().getToken(),
          u = c ? 0 : g.EVENT_SEND_DEFAULT_INTERVAL,
          f = Date.now();
        (s = u),
          ('number' != typeof i ||
            'number' != typeof s ||
            i <= 0 ||
            s < f - i) &&
            ((i = f), Pt().send(B, { noCache: c }, function () {}));
      }
    }),
    (this.trackShare = function (e) {
      if (t) {
        try {
          -1 < p.getSdkType().indexOf('game')
            ? ((e = R().add(e, !0)), r().v('shareQuery: ', e))
            : ((e = R().add(e, !1)), r().v('sharePath: ', e.path));
        } catch (e) {
          r().v('shareAppMessage: ', e);
        }
        return e;
      }
    }),
    (this.trackPageStart = function (e) {
      t && w().addPageStart(e);
    }),
    (this.trackPageEnd = function (e) {
      t && w().addPageEnd(e);
    }),
    (this.onShareAppMessage = function (t) {
      var e = this;
      p.onShareAppMessage(function () {
        return e.trackShare(t());
      });
    }),
    (this.shareAppMessage = function (t) {
      this.trackShare(t), p.shareAppMessage(t);
    });
}
var Gt = [];
function Kt() {}
Kt.prototype = {
  createMethod: function (t, e, n) {
    try {
      t[e] =
        n && n[e]
          ? function () {
              return n[e].apply(n, arguments);
            }
          : function () {
              Gt.push([e, [].slice.call(arguments)]);
            };
    } catch (t) {
      r().v('create method errror: ', t);
    }
  },
  installApi: function (t, e) {
    try {
      for (
        var n =
            'resume,pause,trackEvent,trackPageStart,trackPageEnd,trackShare,setUserid,setOpenid,setUnionid,setSuperProperty'.split(
              ',',
            ),
          i = 0,
          o = n.length;
        i < o;
        i++
      )
        this.createMethod(t, n[i], e);
      if (e)
        for (i = 0, o = Gt.length; i < o; i++) {
          var s = Gt[i];
          try {
            e[s[0]].apply(e, s[1]);
          } catch (t) {
            r().v('impl[v[0]].apply error: ', s[0], t);
          }
        }
    } catch (t) {
      r().v('install api errror: ', t);
    }
  },
};
var Ft = ['https://umini.shujupie.com', 'https://ulogs.umeng.com'],
  qt = 0;
!(function (t) {
  setTimeout(function () {
    !(function t(e, n) {
      e >= Ft.length || n
        ? (n &&
            (function () {
              var t = 'https://umini.shujupie.com';
              (g.LOG_URL = g.LOG_URL.replace(t, Ft[qt])),
                (g.GET_OPENID_URL = g.GET_OPENID_URL.replace(t, Ft[qt])),
                (g.USERINFO_URL = g.USERINFO_URL.replace(t, Ft[qt]));
            })(),
          n && r().v('命中可用服务', Ft[qt]),
          n || r().tip_w('未命中可用服务'))
        : p.request({
            url: Ft[e] + '/uminiprogram_logs/ckdh',
            success: function (n) {
              200 === (n.code || n.status || n.statusCode) &&
              n.data &&
              200 === n.data.code
                ? t((qt = e) + 1, !0)
                : t(e + 1, !1);
            },
            fail: function () {
              t(e + 1, !1);
            },
          });
    })(0, !1);
  }, t);
})(3e3);
var Ht = new Kt(),
  Yt = {
    _inited: !1,
    init: function (t) {
      if (this._inited) r().v('已经实例过，请避免重复初始化');
      else if (t)
        if (t.appKey) {
          'boolean' != typeof t.useOpenid && (t.useOpenid = !0),
            a().set(t),
            r().setDebug(t.debug),
            (this._inited = !0);
          var e = this;
          f.emit(0, t);
          try {
            var n = new jt();
            r().v('成功创建Lib对象'),
              n.init(function () {
                r().v('Lib对象初始化成功'),
                  Ht.installApi(e, n),
                  r().v('安装Lib接口成功'),
                  f.emit(1, t);
              });
          } catch (t) {
            r().w('创建Lib对象异常: ' + t);
          }
        } else r().err('请确保传入正确的appkey');
      else r().err('请正确设置相关信息！');
    },
  };
try {
  Ht.installApi(Yt, null);
} catch (t) {
  r().w('uma赋值异常: ', t);
}
var Jt = 'https://ucc.umeng.com/v1/mini/fetch',
  Xt = 'https://pslog.umeng.com/mini_ablog',
  zt = '2.4.6',
  Qt = 'none',
  Wt = {},
  Bt = Array.isArray;
(Wt.isArray =
  Bt ||
  function (t) {
    return '[object Array]' === toString.call(t);
  }),
  (Wt.isObject = function (t) {
    return t === Object(t) && !Wt.isArray(t);
  }),
  (Wt.isEmptyObject = function (t) {
    if (Wt.isObject(t)) {
      for (var e in t) if (hasOwnProperty.call(t, e)) return !1;
      return !0;
    }
    return !1;
  }),
  (Wt.isUndefined = function (t) {
    return void 0 === t;
  }),
  (Wt.isString = function (t) {
    return '[object String]' === toString.call(t);
  }),
  (Wt.isDate = function (t) {
    return '[object Date]' === toString.call(t);
  }),
  (Wt.isNumber = function (t) {
    return '[object Number]' === toString.call(t);
  }),
  (Wt.each = function (t, e, n) {
    if (null != t) {
      var i = {},
        r = Array.prototype.forEach;
      if (r && t.forEach === r) t.forEach(e, n);
      else if (t.length === +t.length) {
        for (var o = 0, s = t.length; o < s; o++)
          if (o in t && e.call(n, t[o], o, t) === i) return;
      } else
        for (var a in t)
          if (hasOwnProperty.call(t, a) && e.call(n, t[a], a, t) === i) return;
    }
  }),
  (Wt.buildQuery = function (t, e) {
    var n,
      i,
      r = [];
    return (
      void 0 === e && (e = '&'),
      Wt.each(t, function (t, e) {
        (n = encodeURIComponent(t.toString())),
          (i = encodeURIComponent(e)),
          (r[r.length] = i + '=' + n);
      }),
      r.join(e)
    );
  }),
  (Wt.JSONDecode = function (t) {
    if (t) {
      try {
        return JSON.parse(t);
      } catch (t) {
        console.error('JSONDecode error', t);
      }
      return null;
    }
  }),
  (Wt.JSONEncode = function (t) {
    try {
      return JSON.stringify(t);
    } catch (t) {
      console.error('JSONEncode error', t);
    }
  });
var Zt = Object.create(null);
var $t = Object.create(null),
  te = null,
  ee = !1,
  ne = { minFetchIntervalSeconds: 43200 };
function ie(t) {
  t &&
    Wt.each(t, function (t) {
      $t[t.k] = t;
    });
}
function re() {
  var t = this;
  (this.STORAGE_NAME = null),
    f.on(0, function (e) {
      r().v('云配初始化开始...'), t.init(e);
    });
}
re.prototype = {
  setDefaultValues: function (t) {
    ee &&
      Wt.isObject(t) &&
      Wt.each(t, function (t, e) {
        ($t[e] && $t[e].v) || ($t[e] = { v: t });
      });
  },
  getValue: function (t) {
    r().v('从配置项中读取 value, 当前配置为: ', $t),
      r().v('待读取的 key : ', t);
    try {
      if (!ee) return;
      var e = $t[t] || {};
      return (
        r().v('读取相应配置ing..., 结果为: ', e),
        Wt.isNumber(e.e) &&
          Wt.isNumber(e.g) &&
          (r().v('读取到相应配置, 开始数据上报...'),
          (function (t) {
            var e = {
              appkey: a().appKey(),
              sdkType: p.getSdkType(),
              expId: t && t.e,
              groupId: t && t.g,
              clientTs: Date.now(),
              key: t && t.k,
              value: t && t.v,
              umid: A().getId(),
            };
            try {
              p.request({
                url: Xt,
                method: 'POST',
                data: [e],
                success: function (t) {
                  t && 200 === t.statusCode
                    ? r().v('上传数据成功', e)
                    : r().w('ablog 请求成功, 返回结果异常 ', t);
                },
                fail: function (t) {
                  r().w('ablog 请求数据错误 ', e, t);
                },
              });
            } catch (t) {
              r().w('urequest 调用错误', t);
            }
          })(e)),
        e.v
      );
    } catch (e) {
      r().w('getValue error, key: ', t);
    }
  },
  active: function (t) {
    try {
      if (!ee) return;
      var e, n;
      t && t.params && (e = t.params),
        t && t.callback && (n = t.callback),
        r().v('激活配置项: ', e),
        e
          ? (r().v('本地已缓存的配置项: ', $t),
            ie(e),
            r().v('合并后的配置项: ', $t),
            n && n($t),
            r().v('active 结束'))
          : (r().v('配置项为空!! 读取本地配置...'),
            p.getStorage(this.STORAGE_NAME, function (t) {
              t
                ? (ie((t = Wt.JSONDecode(t) || {}).params),
                  r().v('当前本地配置项为: ', $t),
                  n && n($t),
                  r().v('active 结束'))
                : r().v('当前本地配置项为空, 退出激活');
            }));
    } catch (t) {
      r().w('SDK active 错误', t);
    }
  },
  init: function (t) {
    t.appKey &&
      ((te = t.appKey),
      (this.STORAGE_NAME = 'um_remote_config_{{' + te + '}}')),
      te
        ? ee
          ? r().w('SDK 已经初始化, 请避免重复初始化')
          : ((ee = !0), this.setOptions(t), this.active())
        : r().err('请检查您的小程序 appKey, appKey 不能为空');
  },
  setOptions: function (t) {
    if (Wt.isObject(t)) {
      var e = t.minFetchIntervalSeconds;
      Wt.isNumber(e) && (ne.minFetchIntervalSeconds = Math.max(e, 5));
    }
  },
  fetch: function (t) {
    if (ee && this.STORAGE_NAME) {
      var e, n;
      t && t.active && (e = t.active), t && t.callback && (n = t.callback);
      var i = this;
      p.getStorage(this.STORAGE_NAME, function (t) {
        r().v('开始读缓存 data is ', t),
          (t = Wt.JSONDecode(t) || {}).params &&
          t.ts &&
          Date.now() - t.ts < 1e3 * ne.minFetchIntervalSeconds
            ? (r().v(
                '缓存数据存在, 并且本次触发时间距离上次fetch触发时间未超过 fetch 时间间隔, 无需 fetch',
              ),
              n && n(t.params))
            : (function (t) {
                r().v('开始构建 fetch body'),
                  p.getSystemInfo(function (e) {
                    p.getNetworkInfo(function (n) {
                      var i =
                        (i = (n = n || {}).networkType) === Qt
                          ? 'unknown'
                          : i.toUpperCase();
                      (Zt.access = i),
                        (function (t, e) {
                          var n = t.brand || '';
                          if (
                            ((Zt.deviceType = 'Phone'),
                            (Zt.sdkVersion = zt),
                            (Zt.appkey = a().appKey()),
                            (Zt.sdkType = p.getSdkType()),
                            (Zt.umid = A().getId()),
                            t)
                          ) {
                            (Zt.language = t.language || ''),
                              (Zt.os = t.OS),
                              (Zt.osVersion = t.OSVersion),
                              (Zt.deviceName = t.deviceName),
                              (Zt.platformVersion = t.platformVersion),
                              (Zt.platformSdkVersion = t.platformSDKVersion),
                              (Zt.deviceBrand = n);
                            var i = t.resolution.split('*');
                            Wt.isArray(i) &&
                              ((Zt.resolutionHeight = Number(i[0])),
                              (Zt.resolutionWidth = Number(i[1])));
                          }
                          !(function (t) {
                            t &&
                              ((Zt.installTime =
                                t.install_datetime &&
                                Date.parse(t.install_datetime)),
                              (Zt.scene = t.install_scene),
                              (Zt.channel = t.install_channel),
                              (Zt.campaign = t.install_campaign));
                          })(Tt.get()),
                            e && e(Zt);
                        })(e, t);
                    });
                  });
              })(function (t) {
                r().v('缓存数据不存在, 构建 fetch body :', t);
                try {
                  p.request({
                    url: Jt,
                    method: 'POST',
                    data: t,
                    success: function (t) {
                      if (t && 200 === t.statusCode && t.data && t.data.cc) {
                        r().v('fetch 请求成功, 响应数据: ', t.data);
                        var o = Object.create(null);
                        Wt.each(t.data.cc, function (t) {
                          o[t.k] = t;
                        });
                        var s = { ts: Date.now(), params: o };
                        r().v('开始缓存 fetch 请求的云配置结果...'),
                          p.setStorage(
                            i.STORAGE_NAME,
                            Wt.JSONEncode(s),
                            function (t) {
                              r().v('缓存云配置成功, 缓存数据为: ', s),
                                r().v('缓存云配置成功, 成功消息为: ', t),
                                r().v('云配拉取数据是否自动激活: ', e),
                                t &&
                                  e &&
                                  (r().v('激活云配置...'),
                                  i.active({ params: o, callback: n }));
                            },
                          );
                      } else
                        r().w('fetch 请求成功,返回结果异常 ', t.data), n && n();
                    },
                    fail: function (e) {
                      r().w('fetch请求数据错误 ', t, e), n && n();
                    },
                  });
                } catch (t) {
                  r().w('urequest调用错误', t);
                }
              });
      });
    }
  },
};
var oe = '',
  se = {};
function ae(t) {
  t && (oe = t);
}
function ce(t, e) {
  if (t.onShareAppMessage) {
    var n = t.onShareAppMessage;
    t.onShareAppMessage = function (t) {
      var i = n.call(this, t) || {},
        r = (function (t, e) {
          if (!t) return '';
          var n = [];
          for (var i in e)
            '_um_ssrc' !== i && '_um_sts' !== i && n.push(i + '=' + e[i]);
          var r = n.join('&');
          return r ? t + '?' + r : t;
        })(oe, se[oe]);
      return !i.path && r && (i.path = r), e.trackShare.call(this, i);
    };
  }
}
function ue(t, e, n) {
  var i = t[e];
  t[e] = function (t) {
    n.call(this, t), i && i.call(this, t);
  };
}
function fe(t) {
  try {
    Yt.resume(t, !0);
  } catch (t) {
    r().v('onAppShow: ', t);
  }
}
function pe() {
  try {
    Yt.pause();
  } catch (t) {
    r().v('onAppHide: ', t);
  }
}
function de() {
  try {
    ae(this.route), Yt.trackPageStart(this.route);
  } catch (t) {
    r().v('onPageShow: ', t);
  }
}
function le(t) {
  try {
    ae(this.route),
      t && ((e = this.route), (n = t), e && (se[e] = n)),
      r().v('Page onLoad: ', this.route, t);
  } catch (t) {
    r().v('onPageLoad: ', t);
  }
  var e, n;
}
function he() {
  try {
    Yt.trackPageEnd(this.route);
  } catch (t) {
    r().v('onPageHide: ', t);
  }
}
try {
  var ve = App;
  App = function (t) {
    ue(t, 'onLaunch', function () {
      !(function (t) {
        try {
          Yt.init(t);
        } catch (t) {
          r().v('onAppLaunch: ', t);
        }
      })(t.umengConfig);
    }),
      ue(t, 'onShow', fe),
      ue(t, 'onHide', pe),
      ve(t);
  };
} catch (t) {
  r().w('App重写异常');
}
try {
  var ge = Page;
  Page = function (t) {
    ue(t, 'onShow', de),
      ue(t, 'onHide', he),
      ue(t, 'onUnload', he),
      ue(t, 'onLoad', le),
      ce(t, Yt),
      ge(t);
  };
} catch (t) {
  r().w('Page重写异常');
}
try {
  var ye = Component;
  Component = function (t) {
    try {
      t.methods = t.methods || {};
      var e = t.methods;
      ue(e, 'onShow', de),
        ue(e, 'onHide', he),
        ue(e, 'onUnload', he),
        ue(e, 'onLoad', le),
        ce(e, Yt),
        ye(t);
    } catch (e) {
      ye(t);
    }
  };
} catch (t) {
  r().w('Component重写异常');
}
var _e = Yt.init;
Yt.init = function (t) {
  t &&
    t.useOpenid &&
    (r().tip_w(
      '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!',
    ),
    r().tip_w(
      '您选择了使用openid进行统计，请确保使用setOpenid回传openid或通过设置autoGetOpenid为true，并在友盟后台设置secret由友盟帮您获取',
    ),
    r().tip_w(
      '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!',
    )),
    _e.call(Yt, t);
};
var me = new re();
!(function (t, e, i) {
  if ('object' == n(t)) {
    if (e.length) t.rc = i;
    else
      for (var o in i)
        if ({}.hasOwnProperty.call(i, o)) {
          if (t[o]) return void r().v('方法已定义，无法注入此插件方法: ', o);
          i[o] &&
            (t[o] = function () {
              i[o](arguments);
            });
        }
  } else r().v('插件安装失败，宿主对象不能为空');
})(Yt, 'rc', me),
  (wx.uma = Yt),
  (module.exports = Yt);
